#ifndef HICONITEMVIEW_H
#define HICONITEMVIEW_H

#include "devcommon_global.h"

#include <QWidget>
#include <QIcon>
#include <QMargins>

class DEVCOMMONSHARED_EXPORT HIconListViewItem : public QObject
{
    Q_OBJECT
public:
    explicit HIconListViewItem(QObject* parent = nullptr);
    explicit HIconListViewItem(const HIconListViewItem& other, QObject* parent = nullptr);
    HIconListViewItem& operator=(const HIconListViewItem& other);

    QString text() const;
    void setText(const QString &text);

    QIcon icon() const;
    void setIcon(const QIcon &icon);

    QMargins margins() const;
    void setMargins(const QMargins &margins);

    int spacing() const;
    void setSpacing(int spacing);

private:
    QString mText;
    QIcon   mIcon;
    QMargins    mMargins;
    int     mSpacing;
};

class DEVCOMMONSHARED_EXPORT HIconItemView : public QWidget
{
    Q_OBJECT
public:
    enum ViewMode { ListMode, IconMode };
    explicit HIconItemView(HIconListViewItem* item, QWidget *parent = nullptr);
    explicit HIconItemView(const HIconListViewItem& item, QWidget *parent = nullptr);

    ViewMode viewMode() const;
    void setViewMode(const ViewMode &viewMode);

    QSize size() const;
    void setSize(const QSize &size);

    QSize iconSize() const;
    void setIconSize(const QSize &iconSize);

    int index() const;
    void setIndex(int index);

protected:
    virtual void mousePressEvent(QMouseEvent *event);
    virtual void mouseReleaseEvent(QMouseEvent *event);
    virtual void mouseDoubleClickEvent(QMouseEvent *event);
    virtual void keyPressEvent(QKeyEvent *event);
    virtual void keyReleaseEvent(QKeyEvent *event);
    virtual void focusInEvent(QFocusEvent *event);
    virtual void focusOutEvent(QFocusEvent *event);
    virtual void enterEvent(QEvent *event);
    virtual void leaveEvent(QEvent *event);
    virtual void paintEvent(QPaintEvent *event);
signals:
    void itemClicked(int);

public slots:

private:
    QColor mBackground;
    HIconListViewItem mItem;
    ViewMode mViewMode;
    QSize mSize;
    QSize mIconSize;
    int mIndex;
};

#endif // HICONITEMVIEW_H
